package com.example.multipledatasourcesdemo.config;



import com.alibaba.druid.support.http.StatViewServlet;
import com.alibaba.druid.support.http.WebStatFilter;

import com.example.multipledatasourcesdemo.datasource.CmsDataSource;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.env.Environment;

/**
 * <h1>ApplicationConfig</h1>
 * <p>`
 * Spring配置类 代替xml
 * </p>
 * <p>
 * Spring Config Class
 * </p>
 *
 */
@Configuration
public class ApplicationConfig {
	
	private static Logger logger = LoggerFactory.getLogger(ApplicationConfig.class);
	
    @Autowired
    private Environment env;

    /**
     * <p>
     * 初始化默认数据源
     * </P>
     * <p>
     * data source
     * </p>
     */
    @Bean
    public CmsDataSource dataSource() {
        CmsDataSource bean = null;
        try {
            bean = new CmsDataSource(env);
        } catch (Exception e) {
        	logger.error(e.getMessage());
        }
        return bean;
    }

}